package com.ssg1_8;

import java.util.Arrays;

public class ArraysText {
    public static void main(String[] args) {
        //判断两个数是否相等
        int [] arr1=new int []{1,2,3,4};
        int [] arr2=new int[]{2,5,7,8,7};
        boolean isEquals= Arrays.equals(arr1,arr2);
        System.out.println(isEquals);
        //2，String toString(int [] a);输出数组的信息
        System.out.println(Arrays.toString(arr1));
        //3.void fill (int [] arr1,int [] arr2);将指定的值填充到数组之中
        Arrays.fill(arr1,50);
        System.out.println(Arrays.toString(arr1));
        //4.void sort(int [] a);对数组进行排序
        Arrays.sort(arr2);
        System.out.println(Arrays.toString(arr2));
        //5.int binarySearch(int [] a,int key),二分查找
        int [] arr3=new int[]{-78,411,452,12,745,45,45,54};
        int index=Arrays.binarySearch(arr3,45);
        if (index >= 0) {
            System.out.println("找到了索引是:"+index);
        }else {
            System.out.println("很遗憾没有找到！");
        }

    }

}
